#include "file_upload_status.h"
#include "data_build.h"
#include "data_cache.h"
#include "eventloop.h"

using namespace DcAdr;

FileUploadStatus::FileUploadStatus()
{

}

FileUploadStatus::~FileUploadStatus()
{

}

FileUploadStatus &FileUploadStatus::getInstance()
{
    static FileUploadStatus info;
    return info;
}

void FileUploadStatus::FileUploadStatus_send(const FileUploadParam &info, const uint32_t &fileuploadstatus)
{
    Json::Value root;
    Json::Value header;
    Json::Value data;
    Json::Value param;

    //得到请求ID
    std::string reqId = "";
    CommonOprServser::getReqID(reqId);

    header["v"] = Json::Value("1.0.0");
    header["r"] = Json::Value(reqId);
    header["sk"] = Json::Value("Dat_CarData");
    header["m"] = Json::Value("Dat_IT121");
    header["a"] = Json::Value(1); 
    header["e"] = Json::Value(0); 

    param["controllerName"] = global_data::g_controler_code;
    param["taskId"] = info.taskId; // 文件上传 任务ID
    param["fileName"] = info.fileName;
    param["filePath"] = info.filePath;
    param["fileUploadStatus"] = fileuploadstatus; // 文件上传 状态类型

    data["p"] = param;
    root["h"] = header;
    root["d"] = data;

    std::string sendStr = root.toStyledString();

    DataBuild::mqttsend(sendStr);
}